package com.kfm.hotel.controller;

import com.github.pagehelper.PageInfo;
import com.kfm.hotel.domain.SysDict;
import com.kfm.hotel.service.SysDictService;
import com.kfm.hotel.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/sysdict")
public class SysDictController {
    @Autowired
    private SysDictService service;
    @GetMapping
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("sysdict/index");
        return modelAndView;
    }
    @GetMapping("/list")
    public R list(@RequestParam (defaultValue = "1") Integer page,
                 @RequestParam (defaultValue = "10") Integer limit,
                  SysDict sysDict){
        //后端提供分页
        PageInfo<SysDict> list = service.list(sysDict, page, limit);
        return R.ok(list);

    }
    @GetMapping("/add")
    public ModelAndView add(){
        ModelAndView modelAndView = new ModelAndView("sysdict/add");
        return modelAndView;
    }
}
